package com.ls.kdlss.ui.home;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.jcodecraeer.xrecyclerview.ProgressStyle;
import com.jcodecraeer.xrecyclerview.XRecyclerView;
import com.ls.kdlss.R;
import com.zhy.adapter.recyclerview.CommonAdapter;
import com.zhy.adapter.recyclerview.base.ViewHolder;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

public class AnswerFragment extends Fragment {

    @Bind(R.id.xr_view)
    XRecyclerView xrView;

    public static AnswerFragment getInstance(String typeId) {
        AnswerFragment fragment = new AnswerFragment();
        Bundle args = new Bundle();
        args.putString("id", typeId);
        fragment.setArguments(args);
        return fragment;
    }


    private String typeId;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            typeId = getArguments().getString("id");
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_answer, container, false);
        ButterKnife.bind(this, view);
        initView();
        return view;
    }

    private void initView() {
        LinearLayoutManager manager = new LinearLayoutManager(getActivity());
        xrView.setLayoutManager(manager);
        xrView.setRefreshProgressStyle(ProgressStyle.TriangleSkewSpin);
        List<String> data = new ArrayList<>();
        data.add("1");
        data.add("1");
        data.add("1");
        data.add("1");
        xrView.setAdapter(new CommonAdapter<String>(getActivity(), R.layout.cell_answer, data) {
            @Override
            protected void convert(ViewHolder holder, String s, int position) {

            }
        });
    }


    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.unbind(this);
    }
}
